package com.swas.service.impl;

import com.swas.dao.BaseStaticDao;
import com.swas.dao.BaseSurveyDao;
import com.swas.entity.BaseStatic;
import com.swas.entity.BaseStaticExample;
import com.swas.entity.BaseSurvey;
import com.swas.entity.BaseSurveyExample;
import com.swas.service.BaseStaticService;
import com.swas.service.BaseSurveyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class BaseStaticServiceImpl implements BaseStaticService {
    @Autowired
    private BaseStaticDao baseStaticDao;
    @Autowired
    private BaseSurveyDao baseSurveyDao;

    @Override
    public List<BaseStatic> getBaseStaicAll(Integer id) {
        BaseStaticExample baseStaticExample= new BaseStaticExample();
        BaseStaticExample.Criteria criteria = baseStaticExample.createCriteria();
        criteria.andStockidEqualTo(id);
        return baseStaticDao.selectByExample(baseStaticExample);
    }

    @Override
    public boolean addStatic(BaseStatic baseStatic) {
        int i = baseStaticDao.insertSelective(baseStatic);
        return i>0;
    }

    @Override
    public boolean updataStatic(BaseStatic baseStatic) {
        return baseStaticDao.updateByPrimaryKeySelective(baseStatic)>0;
    }

    @Override
    public boolean delStatic(Integer id) {
        return baseStaticDao.deleteByPrimaryKey(id)>0;
    }

    @Override
    public List<BaseSurvey> getBaseSurveyAll(Integer id) {
        BaseSurveyExample baseSurveyExample= new BaseSurveyExample();
        BaseSurveyExample.Criteria criteria = baseSurveyExample.createCriteria();
        criteria.andStockidEqualTo(id);
        return baseSurveyDao.selectByExample(baseSurveyExample);
    }
}
